import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.List;

public class iTunesTVSeriesRenamer {

    /**
     * @param args
     */
    public static void main(String[] args) throws Exception {
        String series = "Malcolm in the Middle";
        int season = 2;
        List<String> episodenames = ReadFromFile.read(series,
                WindowsFilenameRenamer.ENGLISH, season);

        Robot rob = new Robot();
        rob.setAutoDelay(150);
        Thread.sleep(7000);
        System.out.println(episodenames.size());
        for (int i = 0; i < episodenames.size(); i++) {
            // deactivate ahk neo layout, doesn�t work with robot
            // rob.keyPress(KeyEvent.VK_SHIFT);
            // rob.keyPress(KeyEvent.VK_PAUSE);
            // rob.keyRelease(KeyEvent.VK_PAUSE);
            // rob.keyRelease(KeyEvent.VK_SHIFT);

            Toolkit.getDefaultToolkit()
                    .getSystemClipboard()
                    .setContents(new StringSelection(episodenames.get(i)), null);
            Thread.sleep(90);
            rob.keyPress(KeyEvent.VK_CONTROL);
            rob.keyPress('V');
            rob.keyRelease('V');
            rob.keyRelease(KeyEvent.VK_CONTROL);
            Thread.sleep(500);
            rob.mousePress(InputEvent.BUTTON1_MASK);
            rob.mouseRelease(InputEvent.BUTTON1_MASK);
            Thread.sleep(600);

            // reactivate neo layout again
            // rob.keyPress(KeyEvent.VK_SHIFT);
            // rob.keyPress(KeyEvent.VK_PAUSE);
            // rob.keyRelease(KeyEvent.VK_PAUSE);
            // rob.keyRelease(KeyEvent.VK_SHIFT);

        }
    }
}
